#ifndef __BASE_TIME_H_
#define __BASE_TIME_H_

#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <string>
#include <stdio.h>

namespace BASE{
	class Time{
		public:
			static std::string FMT;

			static time_t getNow();

			static int64_t getMicroTime();

			static int64_t getMillTime();

			static size_t getTimeStamp(time_t timestamp, char * buf, int size, bool needUsec = true, const std::string & fmt = Time::FMT);

			static std::string getDateText(time_t timestamp = 0, const std::string & fmt = Time::FMT);

			static time_t fromString(const std::string & timeTxt, const std::string & fmt = Time::FMT);

			static std::string toString(time_t time, const std::string & fmt = Time::FMT);

			static bool checkDay(time_t time1, time_t time2 = time(NULL));
	};

	class TimeCheck{
		public:
			TimeCheck(int32_t _timeOutMillSec);

			void setTimeOut(int32_t _timeOutMillSec);

			bool isTimeOut();
		private:
			int32_t timeOutMillSec;
			int64_t lastCheckTime;
	};


}

#endif
